package com.genntii.examManager.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.genntii.examManager.domain.dto.TeacherDTO;
import com.genntii.examManager.domain.entity.Teacher;
import com.genntii.examManager.domain.entity.User;
import com.genntii.examManager.mapper.TeacherMapper;
import com.genntii.examManager.mapper.UserMapper;
import com.genntii.examManager.service.TeacherService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> implements TeacherService {

    @Resource
    private TeacherMapper teacherMapper;

    @Resource
    private UserMapper userMapper;

    @Override
    public void updateTeacher(TeacherDTO teacherDTO, Long userId) {
        Teacher teacher = teacherMapper.getTeacherByUserId(userId);
        teacher.setName(teacherDTO.getName());
        teacher.setDegree(teacher.getDegree());
        teacher.setDescription(teacher.getDescription());
        teacherMapper.updateById(teacher);
    }
}
